home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / AOCE / Development Tools / Sample Code / Messaging Service Access Module / Internet PMSAM / Internet PMSAM source / ConvertAddress.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-07  |  1.7 KB  |  79 lines  |  [TEXT/MPS ]

  1. /*-------------------------------------------------------------------
  2.  
  3. AOCE Post Office Protocol (POP) / Simple Mail Transfer Protocol (SMTP)
  4. Mail Service Access Module
  5.  
  6. written by Steve Falkenburg-- MacDTS
  7. ©1991-1993 Apple Computer, Inc.
  8.  
  9. --------------
  10. change history
  11. --------------
  12.  
  13. SJF        02/19/93    update for beta build    b1
  14. SJF        10/29/92    update to a11            a11
  15. SJF        06/08/92    update to a8            a8
  16. SJF        02/15/92    first working version    a4.5
  17. SJF        10/16/91    initial coding            a3
  18.  
  19. ---------------------------------------------------------------------*/
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24.  
  25. #include <string.h>
  26.  
  27. #include <MacTCPCommonTypes.h>
  28. #include <AddressXLation.h>
  29. #include "ConvertAddress.h"
  30. #include "network.h"
  31.  
  32. pascal void DNRResultProc(struct hostInfo *hInfoPtr,char *userDataPtr);
  33.  
  34. // ConvertStringToAddr
  35. //
  36. // a MacTCP call to get a host's IP number, given the name of the host
  37. //
  38. OSErr ConvertStringToAddr(char *name,unsigned long *netNum)
  39. {
  40.     struct hostInfo hInfo;
  41.     OSErr result;
  42.     char done = 0x00;
  43.     extern Boolean gCancel;
  44.  
  45.     result = InitRemoteNetStuff();
  46.     if (result!=noErr)
  47.         return result;
  48.         
  49.     if ((result = OpenResolver(nil)) == noErr) {
  50.         result = StrToAddr(name,&hInfo,DNRResultProc,&done);
  51.         if (result == cacheFault)
  52.             while (!done)
  53.                 ; /* wait for cache fault resolver to be called by interrupt */
  54.         CloseResolver();
  55.         if ((hInfo.rtnCode == noErr) || (hInfo.rtnCode == cacheFault)) {
  56.             *netNum = hInfo.addr[0];
  57.             return noErr;
  58.         }
  59.         else
  60.             result = hInfo.rtnCode;
  61.     }
  62.     *netNum = 0;
  63.  
  64.     return result;
  65. }
  66.  
  67.  
  68. // DNRResultProc
  69. //
  70. // completion routine for MacTCP name resolver calls
  71. //
  72. pascal void DNRResultProc(struct hostInfo *hInfoPtr,char *userDataPtr)
  73. {
  74. #pragma unused (hInfoPtr)
  75.  
  76.     *userDataPtr = 0xff;    /* setting the use data to non-zero means we're done */
  77. }
  78.  
  79.